package lkx.demo.test1;

/**
 * @author kunxianli
 * @date 2024/01/16 19:51
 **/
public class TestArray1 {

    public static void main(String[] args) {
        //1. 数组的声明与初始化(方式一)
        int[] a;
        a=new int[2];
        int[] b = {1,2,3};

        //  1.1 数组的声明与初始化(方式二)
        double[] aa;
        aa = new double[]{1.2,2.3,3.4};

        // 1.2 方式三
        String[] bb = {"zhang","qian","sun"};
        // 1.3 其他写法
        String ab[] = {"zhang","qian","sun"};
        int[] aab[];


        //2. 数组元素的调用
        System.out.println(b[0]);
        System.out.println(b[2]);

        //3. 数组的长度
        System.out.println(b.length);

        //4. 如何遍历数组
        for (int i = 0; i < b.length; i++) {
            System.out.println(b[i]);
        }

        //5. 数组元素的默认初始化值
        char[] c = new char[3];
        char empty = 0;
        System.out.println("c[0]:"+(c[0] == empty));

    }
}
